package com.hunan.api.catv.action.column;

import com.hunan.api.catv.action.BaseAction;
import com.hunan.api.catv.common.Api;
import com.hunan.api.catv.entity.Result;
import com.hunan.api.catv.service.biz.cache.CacheBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * api栏目操作
 */
@RestController
@RequestMapping(Api.column)
public class ColumnAction extends BaseAction {

    @Autowired
    CacheBiz cacheBiz;

    @GetMapping("/list")
    public Result list(Integer type, HttpServletRequest request) {
        String version = request.getHeader("v");
        return buildOK(cacheBiz.columnList(type,version), "");
    }

    /**
     * type 1:短视频 3:电视 4:直播
     */
    @GetMapping("/columnList/{type}")
    public Result columnList(@PathVariable("type") Integer type, HttpServletRequest request) {
        String version = request.getHeader("v");
        return buildOK(cacheBiz.newColumnList(type,version), "");
    }
}